﻿<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="AddRecipe.aspx.cs" Inherits="RecipeBookWeb.AddRecipe" %>

<asp:Content ID="AddRecipeContent" ContentPlaceHolderID="MainContent" Runat="Server">

<div class="post">
    <h2 class="title">Add a Recipe</h2>
	<div class="entry">
    <asp:Label runat="server" ID="ErrorLabel" Visible="false" ForeColor="Red" Font-Bold="true" />
    Recipe Name:
	<asp:textbox runat="server" id="name" />
	<asp:RequiredFieldValidator id="requiredName" runat="server" ErrorMessage="You must enter a recipe name."
	    ControlToValidate="name" Display="Dynamic" />
	<br /><br />
            
	    Serving Size:
		<asp:textbox runat="server" id="servingSize" />
		<asp:RequiredFieldValidator id="requiredServingSize" runat="server" Display="Dynamic"
		    ErrorMessage="You must enter a serving size." ControlToValidate="servingSize" />
		<asp:RegularExpressionValidator id="numberValidatorServing" runat="server" Display="Dynamic"
		    ErrorMessage="Serving size must be a number." ControlToValidate="servingSize"
		    ValidationExpression="^\d+$" />
		<br /><br />
        
		Ingredients:<br />
		<asp:GridView runat="server" ID="IngredientGridView" AutoGenerateColumns="false" GridLines="None" Width="98%" ShowHeader="false">
		    <Columns>
		        <asp:BoundField DataField="Amount" ItemStyle-Width="20" />
		        <asp:BoundField DataField="Description" ItemStyle-Width="30%" />
		        <asp:TemplateField ItemStyle-HorizontalAlign="Left">
		            <ItemTemplate>
		                <asp:LinkButton runat="server" CausesValidation="false" OnCommand="RemoveIngredient" Text="Remove" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID") %>' />
		            </ItemTemplate>
		        </asp:TemplateField>
		    </Columns>
		</asp:GridView>
		<asp:Panel ID="ingredientsPanel" runat="server" BorderStyle="None" >
			<asp:textbox runat="server" id="Amount" Width="100" />
			<asp:DropDownList id="IngredientDropDown" runat="server"></asp:DropDownList>
			<br />
		</asp:Panel>
		<asp:Button ID="addIngredient" runat="server" CausesValidation="false" 
            Text="Add" onclick="AddIngredient" Width="75" />
		<br /><br />
            
		Equipment:<br />
		<asp:GridView runat="server" ID="EquipmentGridView" AutoGenerateColumns="false" GridLines="None" Width="98%" ShowHeader="false">
		    <Columns>
		        <asp:BoundField DataField="Description" ItemStyle-Width="30%" />
		        <asp:TemplateField ItemStyle-HorizontalAlign="Left">
		            <ItemTemplate>
		                <asp:LinkButton runat="server" CausesValidation="false" OnCommand="RemoveEquipment" Text="Remove" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID") %>' />
		            </ItemTemplate>
		        </asp:TemplateField>
		    </Columns>
		</asp:GridView>
		<asp:Panel ID="equipmentPanel" runat="server" BorderStyle="None" >
			<asp:DropDownList id="EquipmentDropDown" runat="server"></asp:DropDownList>
			<br />
		</asp:Panel>
		<asp:Button ID="addEquip" runat="server" CausesValidation="false"
		    Text="Add" onclick="AddEquipment" Width="75" />
		<br /><br />
		
		Categories:<br />
		<asp:GridView runat="server" ID="CategoryGridView" AutoGenerateColumns="false" GridLines="None" Width="98%" ShowHeader="false">
		    <Columns>
		        <asp:BoundField DataField="Name" ItemStyle-Width="30%" />
		        <asp:TemplateField ItemStyle-HorizontalAlign="Left">
		            <ItemTemplate>
		                <asp:LinkButton runat="server" CausesValidation="false" OnCommand="RemoveCategory" Text="Remove" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID") %>' />
		            </ItemTemplate>
		        </asp:TemplateField>
		    </Columns>
		</asp:GridView>
		<asp:Panel ID="categoryPanel" runat="server" BorderStyle="None">
		    <asp:DropDownList ID="CategoryDropDown" runat="server"></asp:DropDownList>
		    <br />
		</asp:Panel>
        <asp:Button ID="addCategory" runat="server" CausesValidation="false"
            Text="Add" OnClick="AddCategory" Width="75" />
        <br /><br />
            
		Instructions:<br />
		<asp:textbox runat="server" id="instructions" Rows="5" TextMode="MultiLine" Width="98%" />
		<asp:RequiredFieldValidator id="requiredInstructions" runat="server"
		    ErrorMessage="You must enter instructions." ControlToValidate="instructions" />
		<br /><br />
            
		Nutritional Info (optional):<br />
		<asp:textbox runat="server" id="nutrition" Rows="5" TextMode="MultiLine" Width="98%" />
		<br /><br />
			
		<asp:button runat="server" id="submit" text="Submit" onclick="SubmitRecipe" />
            
		</div>
    </div>
</asp:Content>